package com.webcams.core.settings;

import java.util.ArrayList;

import com.webcams.ui.R;

import android.content.Context;

public class SettingsManager extends ArrayList<Setting> {

	private static final long serialVersionUID = 1L;

	public static final String PREFS_NAME = "Settings";

	public static final String GPS = "gps";

	private static SettingsManager instance;
	private Context context;

	public static SettingsManager getInstance(Context context){
		if(instance == null) {
			instance = new SettingsManager(context);
		}
		
		return instance;
	}

	
	public SettingsManager(Context context){
		this.context = context;
		add(new GPSSetting(context.getString(R.string.settings_gps), GPS, false));
		loadSettings();
	}
	
	public Boolean getBooleanPropertyValue(String propertyName) {
		for(Setting s : this) {
			if(s instanceof BooleanSetting && s.getPropertyName().equals(propertyName)) {
				return ((BooleanSetting)s).getValue();
			}
		}
		return false;
	}
	
	public void loadSettings(){
		for(Setting s : this){
			s.loadValue(context);
		}
	}
}
